package com.ts.hidden.fragment.login;

import com.ts.hidden.R;

import android.app.Activity;
import android.app.Fragment;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;

public class IntroduceFragment extends Fragment implements OnClickListener {

    private ImageView imgNext;

    public static IntroduceFragment newInstance(String s) {
        IntroduceFragment f = new IntroduceFragment();
        return f;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.introduce_fragment, container, false);
        initLayout(rootView);
        initListener();
        return rootView;
    }

    private void initLayout(View rootView) {
        imgNext = (ImageView) rootView.findViewById(R.id.login_page1_next);
        AnimationDrawable animationDrawable = (AnimationDrawable) imgNext.getBackground();
        animationDrawable.start();
    }

    private void initListener() {
        imgNext.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
        case R.id.login_page1_next:
            listener.onIMainNext();
            break;

        default:
            break;
        }
    }

    public interface IMainListener {
        void onIMainNext();
    }
    private IMainListener listener;
    
    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        if(activity instanceof IMainListener) {
            listener = (IMainListener) activity;
        }
    }
    @Override
    public void onDetach() {
        super.onDetach();
        listener = null;
    }
}
